<template>
  <div class="auditdashboard-report">
    <dv-loading v-if="loading"></dv-loading>
    <Auditdashboard
      v-else
      :dataList="dataList"
      :temperatureValue="temperatureValue"
      :StationLevelValue="StationLevelValue"
      :chartData1="chartData1"
      :chartData2="chartData2"
      :chartData3="chartData3"
      :chartType="'pictorialBar'"
      @Checkyear="checkyear"
    />
  </div>
</template>
<script>
import Auditdashboard from "../../components/auditdashboard/Auditdashboard";
import {
  temperature,
  PanelLineLevel,
  AuditDashboardBudgetPerformanceController,
  FengShuiSystemRankinDaoMonthDimension,
  IndexRankingControllerStationLevel,
  WaterVolumeStationLevel,
} from "../../api/base8090.js";
import { mapState } from "vuex";
export default {
  name: "auditdashboard",
  components: {
    Auditdashboard,
  },
  created() {
    this.timer = setInterval(() => {
      if (document.readyState === "complete") {
        this.loading = false;
        window.clearInterval(this.timer);
      }
    }, 1000);
    this.initData();
  },
  data() {
    return {
      loading: true,
      timer: null,
      dataList: [],
      temperatureValue: {},
      StationLevelValue: {},
      chartData1: {},
      chartData2: {},
      chartData3: {},
      queryParmas: {
        stationCode: sessionStorage.getItem("stationCode"),
        years: new Date().getFullYear() + "",
      },
    };
  },
  methods: {
    initData() {
      this.dataList = [];
      this.temperatureValue = {};
      this.StationLevelValue = {};
      this.chartData1 = {};
      this.chartData2 = {};
      this.chartData3 = {};
      temperature(this.queryParmas).then((res) => {
        if (res.code == 200) {
          this.temperatureValue = res.data;
        }
      });
      PanelLineLevel(this.queryParmas).then((res) => {
        if (res.code == 200) {
          this.StationLevelValue = res.data;
        }
      });
      // console.log("预算执行情况",res.data)
      AuditDashboardBudgetPerformanceController(this.queryParmas).then(
        (res) => {
          if (res.code == 200) {
            this.dataList = res.data;
            // this.dataList =[{name:"应急照明用电预算",actualValue:"192231331131",budgetValue:"22223133113"}];
          }
        }
      );
      // console.log("总能耗排名", this.chartData);
      IndexRankingControllerStationLevel(this.queryParmas).then((res) => {
        if (res.code == 200) {
          this.chartData1 = res.data;
        }
      });
      // console.log("用水量", this.chartData);
      WaterVolumeStationLevel(this.queryParmas).then((res) => {
        if (res.code == 200) {
          this.chartData2 = res.data;
        }
      });
      // console.log("风水系统排名", this.chartData);
      FengShuiSystemRankinDaoMonthDimension(this.queryParmas).then((res) => {
        if (res.code == 200) {
          this.chartData3 = res.data;
        }
      });
    },
    checkyear(year) {
      this.queryParmas.years = year;
      this.initData();
    },
  },
  computed: {
    ...mapState(["stationCode"]),
  },

  watch: {
    stationCode(newVal, oldVal) {
      if (newVal != oldVal) {
        this.queryParmas.stationCode = newVal;
        this.initData();
      }
    },
  },
};
</script>
<style lang="less" scoped>
.auditdashboard-report {
  width: 100%;
  height: 100%;
}
</style>
